package com.hospital.controller;

import com.hospital.constant.MessageConstant;
import com.hospital.dto.DeptBedQueryDTO;
import com.hospital.result.PageResult;
import com.hospital.result.Result;
import com.hospital.service.BedService;
import com.hospital.vo.BedUsageVO;
import com.hospital.vo.DepartmentBedVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/bed")
@Slf4j
@Api(tags = "4.病床管理")
public class BedController {
    @Autowired
    private BedService bedService;

    @GetMapping("/list")
    @ApiOperation("获取各科室病床列表")
    public Result<List<DepartmentBedVO>> getDepartmentBedList(){
        log.info("获取各科室病床列表");
        List<DepartmentBedVO> departmentBedVOList = bedService.getDepartmentBedList();
        return Result.success(departmentBedVOList, MessageConstant.QUERY_SUCCESS);
    }

    @GetMapping("/")
    @ApiOperation("获取指定科室病床列表")
    public Result<PageResult> getDepartmentBedByDeptId(DeptBedQueryDTO deptBedQueryDTO){
        log.info("获取指定科室病床列表: {}", deptBedQueryDTO);
        PageResult pageResult = bedService.getDepartmentBedByDeptId(deptBedQueryDTO);
        return Result.success(pageResult, MessageConstant.QUERY_SUCCESS);
    }

    @GetMapping("/usage")
    @ApiOperation("获取病床使用率")
    public Result<List<BedUsageVO>> getDepartmentBedUsage(){
        log.info("获取病床使用率");
        List<BedUsageVO> bedUsageVOList = bedService.getBedUsage();
        return Result.success(bedUsageVOList, MessageConstant.QUERY_SUCCESS);
    }
}
